package com.orkasgb.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.orkasgb.common.CommonResult;
import com.orkasgb.entity.OrkasgbTaskDetailsDataEntity;
import com.orkasgb.entity.OrkasgbTaskEntity;
import com.orkasgb.service.IOrkasgbTaskService;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.Serializable;
import java.util.List;

/**
 * 任务信息表(TOrkasgbTask)表控制层
 *
 * @version 1.0.0
 * @since 2024-09-08 21:17:23
 */
@RestController
@RequestMapping("orkasgbTask")
public class OrkasgbTaskController {
	
	/**
	 * 服务对象
	 */
	@Resource
	private IOrkasgbTaskService orkasgbTaskService;
	
	/**
	 * 通过主键查询单条数据
	 *
	 * @param id 主键
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbTask/{id}")
	public CommonResult<OrkasgbTaskEntity> getOrkasgbTask (@PathVariable("id") Serializable id) {
		return CommonResult.ofSuccess(orkasgbTaskService.getOrkasgbTask(id));
	}
	
	/**
	 * 通过条件查询多条数据
	 *
	 * @param orkasgbTask 实体查询参数
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbTaskList")
	public CommonResult<List<OrkasgbTaskEntity>> getOrkasgbTaskList (@ModelAttribute OrkasgbTaskEntity orkasgbTask) {
		return CommonResult.ofSuccess(orkasgbTaskService.getOrkasgbTaskList(orkasgbTask));
	}
	
	/**
	 * 通过条件查询多条数据
	 *
	 * @param orkasgbTask 实体查询参数
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbTaskDetailsDataList")
	public CommonResult<IPage<OrkasgbTaskDetailsDataEntity>> getOrkasgbTaskDetailsDataList (@ModelAttribute OrkasgbTaskDetailsDataEntity orkasgbTask) {
		return CommonResult.ofSuccess(orkasgbTaskService.getOrkasgbTaskDetailsDataList(orkasgbTask));
	}
	
	/**
	 * 通过条件查询多条数据(分页查询)
	 *
	 * @param orkasgbTask 查询参数
	 * @return 单条数据
	 */
	@GetMapping("getOrkasgbTaskPageDataList")
	public CommonResult<IPage<OrkasgbTaskEntity>> getOrkasgbTaskPageDataList (@ModelAttribute OrkasgbTaskEntity orkasgbTask) {
		return CommonResult.ofSuccess(new Page<OrkasgbTaskEntity>().setRecords(orkasgbTaskService.getOrkasgbTaskPageDataList(orkasgbTask)));
	}
	
	/**
	 * 新增数据
	 *
	 * @param orkasgbTaskDetails 实体对象
	 * @return 新增结果
	 */
	@PostMapping("addOrkasgbTask")
	public CommonResult<Integer> addOrkasgbTask (@RequestBody OrkasgbTaskDetailsDataEntity orkasgbTaskDetails) {
		return CommonResult.ofSuccess(orkasgbTaskService.addOrkasgbTask(orkasgbTaskDetails));
	}
	
	/**
	 * 修改数据
	 *
	 * @param orkasgbTaskDetails 实体对象
	 * @return 修改结果
	 */
	@PutMapping("updateOrkasgbTask")
	public CommonResult<Integer> updateOrkasgbTask (@RequestBody OrkasgbTaskDetailsDataEntity orkasgbTaskDetails) {
		return CommonResult.ofSuccess(orkasgbTaskService.updateOrkasgbTask(orkasgbTaskDetails));
	}
	
	/**
	 * 修改或者新增数据
	 *
	 * @param orkasgbTaskList 实体对象
	 * @return 操作结果
	 */
	@PostMapping("addOrUpdateOrkasgbTask")
	public CommonResult<Integer> addOrUpdateOrkasgbTask (@RequestBody List<OrkasgbTaskEntity> orkasgbTaskList) {
		return CommonResult.ofSuccess(orkasgbTaskService.addOrUpdateOrkasgbTask(orkasgbTaskList).size());
	}
	
	/**
	 * 删除数据
	 *
	 * @param idList 主键结合
	 * @return 删除结果
	 */
	@DeleteMapping("deleteOrkasgbTaskByIds")
	public CommonResult<Integer> deleteOrkasgbTaskByIds (@RequestParam("idList") List<Long> idList) {
		return CommonResult.ofSuccess(orkasgbTaskService.deleteOrkasgbTaskByIds(idList));
	}
	
}

